
#include <assert.h>
#include "app_platform/cmd_obj.h"
#include "app_platform/cmd_obj_ext.h"
#include "app_platform/cntl_info.h"
#include "app_platform/intf_service_control.h"
#include "storagedao_adaptor.h"
#include "storagedao_req_resp.h"


std::string g_sstoragedaoStandAlone;
#include "app_platform/res_factory.h"
#include "c2cplatform/component/dal/dal_set.h"

using namespace c2cplatform::component::dal;

///////////////////////
// class CStorageDaoSvcFactory
int CStorageDaoSvcFactory::init(void* pvParam)
{
	IUserDefineCntl* pCntl = reinterpret_cast<IUserDefineCntl*>(pvParam);
	assert(pCntl);
		CDAL_SET->AddCmd("0xc05e1813");
		CDAL_SET->AddCmd("0xc05e1808");
		CDAL_SET->AddCmd("0xc05e1801");
		CDAL_SET->AddCmd("0xc05e1818");
		CDAL_SET->AddCmd("0xc05e1814");
		CDAL_SET->AddCmd("0xc05e1809");
		CDAL_SET->AddCmd("0xc05e1802");
		CDAL_SET->AddCmd("0xc05e1819");
		CDAL_SET->AddCmd("0xc05e1816");
		CDAL_SET->AddCmd("0xc05e1817");
		CDAL_SET->AddCmd("0xc05e1811");
		CDAL_SET->AddCmd("0xc05e1812");
		CDAL_SET->AddCmd("0xc05e1807");
		CDAL_SET->AddCmd("0xc05e1804");
		CDAL_SET->AddCmd("0xc05e1821");
		CDAL_SET->AddCmd("0xc05e1822");
		CDAL_SET->AddCmd("0xc05e1805");
		CDAL_SET->AddCmd("0xc05e1806");
		CDAL_SET->AddCmd("0xc05e1815");
		CDAL_SET->AddCmd("0xc05e1810");
		CDAL_SET->AddCmd("0xc05e1820");
		CDAL_SET->AddCmd("0xc05e1803");

	return CStorageDao::Initialize(pCntl);
}

int CStorageDaoSvcFactory::CXYZTimerHandler::OnTimer(int iTimerId)
{
    assert(0);
	return 0;
}

int CStorageDaoSvcFactory::fini(void* pvParam)
{
    return 0;
}

uint32_t CStorageDaoSvcFactory::getCateId() const
{   
	//方法已废弃
    return 0;
}

IService* CStorageDaoSvcFactory::createService(uint32_t dwcmdId)
{
    return (new CStorageDaoService(dwcmdId));
}

void CStorageDaoSvcFactory::getServiceType(ServiceTypeMap_T& mapSvcType)
{
	mapSvcType[STORAGEDAO_ADDDISASSEMBLEBILL_REQ_CMD_ID] = true;
	mapSvcType[STORAGEDAO_ADDLOSEBILLOROVERFLOWBILL_REQ_CMD_ID] = true;
	mapSvcType[STORAGEDAO_ADDSTOCK_REQ_CMD_ID] = true;
	mapSvcType[STORAGEDAO_ADDSTOCKCHECK_REQ_CMD_ID] = true;
	mapSvcType[STORAGEDAO_DELETEDISASSEMBLEBILL_REQ_CMD_ID] = true;
	mapSvcType[STORAGEDAO_DELETELOSEBILLOROVERFLOWBILL_REQ_CMD_ID] = true;
	mapSvcType[STORAGEDAO_DELETESTOCK_REQ_CMD_ID] = true;
	mapSvcType[STORAGEDAO_DELETESTOCKCHECK_REQ_CMD_ID] = true;
	mapSvcType[STORAGEDAO_GETDISASSEMBLEBILLBYSYSNOS_REQ_CMD_ID] = true;
	mapSvcType[STORAGEDAO_GETDISASSEMBLEBILLLIST_REQ_CMD_ID] = true;
	mapSvcType[STORAGEDAO_GETLOSEBILLOROVERFLOWBILLBYSYSNOS_REQ_CMD_ID] = true;
	mapSvcType[STORAGEDAO_GETLOSEBILLOROVERFLOWBILLLIST_REQ_CMD_ID] = true;
	mapSvcType[STORAGEDAO_GETSTOCKBRANCH_RELBYSYSNO_REQ_CMD_ID] = true;
	mapSvcType[STORAGEDAO_GETSTOCKBYSYSNOS_REQ_CMD_ID] = true;
	mapSvcType[STORAGEDAO_GETSTOCKCHECKBYSYSNOS_REQ_CMD_ID] = true;
	mapSvcType[STORAGEDAO_GETSTOCKCHECKLIST_REQ_CMD_ID] = true;
	mapSvcType[STORAGEDAO_GETSTOCKLIST_REQ_CMD_ID] = true;
	mapSvcType[STORAGEDAO_MODIFYSTOCKBRANCH_REL_REQ_CMD_ID] = true;
	mapSvcType[STORAGEDAO_UPDATADISASSEMBLEBILL_REQ_CMD_ID] = true;
	mapSvcType[STORAGEDAO_UPDATALOSEBILLOROVERFLOWBILL_REQ_CMD_ID] = true;
	mapSvcType[STORAGEDAO_UPDATASTOCKCHECK_REQ_CMD_ID] = true;
	mapSvcType[STORAGEDAO_UPDATESTOCK_REQ_CMD_ID] = true;
}

////////////////////////
// class CStorageDaoService
CStorageDaoService::CStorageDaoService(uint32_t dwcmdId) 
: m_dwcmdId(dwcmdId)
{
    m_pSvc = new CStorageDao;
}

void CStorageDaoService::Reset() 
{ 
	m_pSvc -> Reset();
}
    
void CStorageDaoService::getCmdIdRange(uint32_t& dwcmdIdBegin, uint32_t& dwcmdIdEnd) const 
{ 
    dwcmdIdBegin = m_dwcmdId;
    dwcmdIdEnd = m_dwcmdId;
} 
	
int CStorageDaoService::Execute(CCmdObj& oCmd)
{
	switch(oCmd.getCmdId())
	{
	case STORAGEDAO_ADDDISASSEMBLEBILL_REQ_CMD_ID:
        return AddDisassembleBill(oCmd);
	case STORAGEDAO_ADDLOSEBILLOROVERFLOWBILL_REQ_CMD_ID:
        return AddLoseBillOrOverFlowBill(oCmd);
	case STORAGEDAO_ADDSTOCK_REQ_CMD_ID:
        return AddStock(oCmd);
	case STORAGEDAO_ADDSTOCKCHECK_REQ_CMD_ID:
        return AddStockCheck(oCmd);
	case STORAGEDAO_DELETEDISASSEMBLEBILL_REQ_CMD_ID:
        return DeleteDisassembleBill(oCmd);
	case STORAGEDAO_DELETELOSEBILLOROVERFLOWBILL_REQ_CMD_ID:
        return DeleteLoseBillOrOverFlowBill(oCmd);
	case STORAGEDAO_DELETESTOCK_REQ_CMD_ID:
        return DeleteStock(oCmd);
	case STORAGEDAO_DELETESTOCKCHECK_REQ_CMD_ID:
        return DeleteStockCheck(oCmd);
	case STORAGEDAO_GETDISASSEMBLEBILLBYSYSNOS_REQ_CMD_ID:
        return GetDisassembleBillBySysNos(oCmd);
	case STORAGEDAO_GETDISASSEMBLEBILLLIST_REQ_CMD_ID:
        return GetDisassembleBillList(oCmd);
	case STORAGEDAO_GETLOSEBILLOROVERFLOWBILLBYSYSNOS_REQ_CMD_ID:
        return GetLoseBillOrOverFlowBillBySysNos(oCmd);
	case STORAGEDAO_GETLOSEBILLOROVERFLOWBILLLIST_REQ_CMD_ID:
        return GetLoseBillOrOverFlowBillList(oCmd);
	case STORAGEDAO_GETSTOCKBRANCH_RELBYSYSNO_REQ_CMD_ID:
        return GetStockBranch_RelBySysNo(oCmd);
	case STORAGEDAO_GETSTOCKBYSYSNOS_REQ_CMD_ID:
        return GetStockBySysNos(oCmd);
	case STORAGEDAO_GETSTOCKCHECKBYSYSNOS_REQ_CMD_ID:
        return GetStockCheckBySysNos(oCmd);
	case STORAGEDAO_GETSTOCKCHECKLIST_REQ_CMD_ID:
        return GetStockCheckList(oCmd);
	case STORAGEDAO_GETSTOCKLIST_REQ_CMD_ID:
        return GetStockList(oCmd);
	case STORAGEDAO_MODIFYSTOCKBRANCH_REL_REQ_CMD_ID:
        return ModifyStockBranch_Rel(oCmd);
	case STORAGEDAO_UPDATADISASSEMBLEBILL_REQ_CMD_ID:
        return UpdataDisassembleBill(oCmd);
	case STORAGEDAO_UPDATALOSEBILLOROVERFLOWBILL_REQ_CMD_ID:
        return UpdataLoseBillOrOverFlowBill(oCmd);
	case STORAGEDAO_UPDATASTOCKCHECK_REQ_CMD_ID:
        return UpdataStockCheck(oCmd);
	case STORAGEDAO_UPDATESTOCK_REQ_CMD_ID:
        return UpdateStock(oCmd);
	default:
		assert(0);
	}
	return 0;
}

int CStorageDaoService::AddDisassembleBill(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageDaoAddDisassembleBillReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageDaoAddDisassembleBillResp oResp;
	
    oResp.dwResult = m_pSvc->AddDisassembleBill(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.DisassembleBillInfo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve,
		oReq.DisassembleBillSysNo
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;
	oResp.DisassembleBillSysNo = oReq.DisassembleBillSysNo;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageDaoService::AddLoseBillOrOverFlowBill(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageDaoAddLoseBillOrOverFlowBillReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageDaoAddLoseBillOrOverFlowBillResp oResp;
	
    oResp.dwResult = m_pSvc->AddLoseBillOrOverFlowBill(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.LoseBillInfo,
		oReq.OverFlowBillInfo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve,
		oReq.OverFlowBillSysNo
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;
	oResp.OverFlowBillSysNo = oReq.OverFlowBillSysNo;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageDaoService::AddStock(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageDaoAddStockReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageDaoAddStockResp oResp;
	
    oResp.dwResult = m_pSvc->AddStock(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.StockInfo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve,
		oReq.StockSysNo
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;
	oResp.StockSysNo = oReq.StockSysNo;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageDaoService::AddStockCheck(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageDaoAddStockCheckReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageDaoAddStockCheckResp oResp;
	
    oResp.dwResult = m_pSvc->AddStockCheck(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.StockCheckMasterInfo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve,
		oReq.StockCheckMasterSysNo
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;
	oResp.StockCheckMasterSysNo = oReq.StockCheckMasterSysNo;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageDaoService::DeleteDisassembleBill(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageDaoDeleteDisassembleBillReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageDaoDeleteDisassembleBillResp oResp;
	
    oResp.dwResult = m_pSvc->DeleteDisassembleBill(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.DisassemblebillSysNos,
		oReq.inReserve,
		oReq.errmsg,
		oReq.errorCode,
		oReq.errorMsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.errorCode = oReq.errorCode;
	oResp.errorMsg = oReq.errorMsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageDaoService::DeleteLoseBillOrOverFlowBill(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageDaoDeleteLoseBillOrOverFlowBillReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageDaoDeleteLoseBillOrOverFlowBillResp oResp;
	
    oResp.dwResult = m_pSvc->DeleteLoseBillOrOverFlowBill(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.FLoseBillSysNo,
		oReq.FOverFlowBillSysNo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.errorCode,
		oReq.errorMsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.errorCode = oReq.errorCode;
	oResp.errorMsg = oReq.errorMsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageDaoService::DeleteStock(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageDaoDeleteStockReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageDaoDeleteStockResp oResp;
	
    oResp.dwResult = m_pSvc->DeleteStock(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.FStockSysNo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.errorCode,
		oReq.errorMsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.errorCode = oReq.errorCode;
	oResp.errorMsg = oReq.errorMsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageDaoService::DeleteStockCheck(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageDaoDeleteStockCheckReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageDaoDeleteStockCheckResp oResp;
	
    oResp.dwResult = m_pSvc->DeleteStockCheck(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.StockCheckMasterSysNos,
		oReq.inReserve,
		oReq.errmsg,
		oReq.errorCode,
		oReq.errorMsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.errorCode = oReq.errorCode;
	oResp.errorMsg = oReq.errorMsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageDaoService::GetDisassembleBillBySysNos(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageDaoGetDisassembleBillBySysNosReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageDaoGetDisassembleBillBySysNosResp oResp;
	
    oResp.dwResult = m_pSvc->GetDisassembleBillBySysNos(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.DisassembleBillSysnoList,
		oReq.inReserve,
		oReq.errmsg,
		oReq.DisassembleBillList,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.DisassembleBillList = oReq.DisassembleBillList;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageDaoService::GetDisassembleBillList(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageDaoGetDisassembleBillListReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageDaoGetDisassembleBillListResp oResp;
	
    oResp.dwResult = m_pSvc->GetDisassembleBillList(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.DisassembleBillFilter,
		oReq.inReserve,
		oReq.errmsg,
		oReq.total,
		oReq.DisassembleBillList,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.total = oReq.total;
	oResp.DisassembleBillList = oReq.DisassembleBillList;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageDaoService::GetLoseBillOrOverFlowBillBySysNos(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageDaoGetLoseBillOrOverFlowBillBySysNosReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageDaoGetLoseBillOrOverFlowBillBySysNosResp oResp;
	
    oResp.dwResult = m_pSvc->GetLoseBillOrOverFlowBillBySysNos(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.LoseBillSysNoList,
		oReq.OverFlowSysNoList,
		oReq.inReserve,
		oReq.errmsg,
		oReq.LoseBillList,
		oReq.OverFlowList,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.LoseBillList = oReq.LoseBillList;
	oResp.OverFlowList = oReq.OverFlowList;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageDaoService::GetLoseBillOrOverFlowBillList(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageDaoGetLoseBillOrOverFlowBillListReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageDaoGetLoseBillOrOverFlowBillListResp oResp;
	
    oResp.dwResult = m_pSvc->GetLoseBillOrOverFlowBillList(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.OverFlowBillOrLoseBillFilter,
		oReq.inReserve,
		oReq.errmsg,
		oReq.total,
		oReq.LoseBillList,
		oReq.OverFlowList,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.total = oReq.total;
	oResp.LoseBillList = oReq.LoseBillList;
	oResp.OverFlowList = oReq.OverFlowList;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageDaoService::GetStockBranch_RelBySysNo(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageDaoGetStockBranch_RelBySysNoReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageDaoGetStockBranch_RelBySysNoResp oResp;
	
    oResp.dwResult = m_pSvc->GetStockBranch_RelBySysNo(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.StockSysNo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve,
		oReq.StockBranchList
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;
	oResp.StockBranchList = oReq.StockBranchList;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageDaoService::GetStockBySysNos(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageDaoGetStockBySysNosReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageDaoGetStockBySysNosResp oResp;
	
    oResp.dwResult = m_pSvc->GetStockBySysNos(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.StockSysnoList,
		oReq.inReserve,
		oReq.errmsg,
		oReq.StockList,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.StockList = oReq.StockList;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageDaoService::GetStockCheckBySysNos(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageDaoGetStockCheckBySysNosReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageDaoGetStockCheckBySysNosResp oResp;
	
    oResp.dwResult = m_pSvc->GetStockCheckBySysNos(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.StockCheckMasterSysNoList,
		oReq.inReserve,
		oReq.errmsg,
		oReq.StockCheckList,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.StockCheckList = oReq.StockCheckList;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageDaoService::GetStockCheckList(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageDaoGetStockCheckListReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageDaoGetStockCheckListResp oResp;
	
    oResp.dwResult = m_pSvc->GetStockCheckList(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.StockCheckFilter,
		oReq.inReserve,
		oReq.errmsg,
		oReq.total,
		oReq.StockCheckList,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.total = oReq.total;
	oResp.StockCheckList = oReq.StockCheckList;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageDaoService::GetStockList(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageDaoGetStockListReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageDaoGetStockListResp oResp;
	
    oResp.dwResult = m_pSvc->GetStockList(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.StockFilter,
		oReq.inReserve,
		oReq.errmsg,
		oReq.total,
		oReq.StockList,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.total = oReq.total;
	oResp.StockList = oReq.StockList;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageDaoService::ModifyStockBranch_Rel(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageDaoModifyStockBranch_RelReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageDaoModifyStockBranch_RelResp oResp;
	
    oResp.dwResult = m_pSvc->ModifyStockBranch_Rel(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.StockSysNo,
		oReq.BranchSysNos,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageDaoService::UpdataDisassembleBill(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageDaoUpdataDisassembleBillReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageDaoUpdataDisassembleBillResp oResp;
	
    oResp.dwResult = m_pSvc->UpdataDisassembleBill(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.DisassembleBillInfo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageDaoService::UpdataLoseBillOrOverFlowBill(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageDaoUpdataLoseBillOrOverFlowBillReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageDaoUpdataLoseBillOrOverFlowBillResp oResp;
	
    oResp.dwResult = m_pSvc->UpdataLoseBillOrOverFlowBill(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.LoseBillInfo,
		oReq.OverFlowBillInfo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageDaoService::UpdataStockCheck(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageDaoUpdataStockCheckReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageDaoUpdataStockCheckResp oResp;
	
    oResp.dwResult = m_pSvc->UpdataStockCheck(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.StockCheckMasterInfo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


int CStorageDaoService::UpdateStock(CCmdObj& oCmd)
{
	char* pBuf = NULL; uint32_t nLen = 0;
    oCmd.getBuffer(pBuf, nLen);
    CByteStreamNetwork bs(pBuf, nLen);
    bs.isStoring(false);
    bs.setVersion(oCmd.getVersion());
    CStorageDaoUpdateStockReq oReq;
    if(!oReq.Serialize(bs))
    {
        m_sLastErrMsg = "Req.Serialize(bs) failed.";
        return -1;
    }

    CCntlInfo oCntlInfo;
    oCntlInfo.setCntl(reinterpret_cast<void*>(m_pSvcCntl));
    oCntlInfo.setOperatorUin(oCmd.getOperatorUin());
	oCntlInfo.setOperatorClientIP(oCmd.getOperatorClientIP());
	oCntlInfo.setOperatorKey(oCmd.getOperatorKey());
    oCntlInfo.setRouteKey(oCmd.getUin());
    oCntlInfo.setCmdId(oCmd.getCmdId());
    oCntlInfo.setNetioClientIP(oCmd.getNetioClientIP());
	oCntlInfo.setSerialNo(oCmd.getSerialNo());
	oCntlInfo.setPkgTimestamp(oCmd.getPkgTimestamp());
	
	if (oCmd.getVersion() == 3)
    {
        CCmdObjExt& oCmdExt = dynamic_cast<CCmdObjExt&>(oCmd);
        oCntlInfo.setAppId(oCmdExt.getReserve1());
        oCntlInfo.setDomainId(oCmdExt.getReserve2());
    }
	
	CStorageDaoUpdateStockResp oResp;
	
    oResp.dwResult = m_pSvc->UpdateStock(
		oCntlInfo,
		oReq.machineKey,
		oReq.source,
		oReq.sceneId,
		oReq.option,
		oReq.StockInfo,
		oReq.inReserve,
		oReq.errmsg,
		oReq.outReserve
    );
	oResp.errmsg = oReq.errmsg;
	oResp.outReserve = oReq.outReserve;

    return m_pSvcCntl->putSvcObj(&oResp, oResp.dwResult);
}


#include "svc_main.h"

IServiceFactory* GetServiceFactory(void)
{
    return CSvcFactorySingleton::Instance();
}
